﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Threading;
using INTEX.SCHEDULER;
namespace WPFExcelReport
{
    public partial class SYTFFAPS
    {
        #region ==IsShowGantt===========
        public static readonly DependencyProperty IsShowGanttProperty = DependencyProperty.Register("IsShowGantt",
            typeof(bool), typeof(SYTFFAPS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowGanttChanged));
        public bool IsShowGantt
        {
            get
            {
                return (bool)GetValue(IsShowGanttProperty);
            }
            set
            {
                SetValue(IsShowGanttProperty, value);
            }
        }
        private static void OnIsShowGanttChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as SYTFFAPS;
            if (src != null)
            {
                src.IsShowGantt = (bool)e.NewValue;
            }
        }

        #endregion 

        public SYTFFAPS()
        {
            InitializeComponent();
            this.Name = "染整智能调度";
            cAV33.KSTKRS = "  ";
            cAV33.KST = "0600";
            cAV33.AMTYP = "DXJ".PadRight(8);
            cAV33.AGANG = "FX".PadRight(15);
        }
        private void ReSetTab()
        {
            IsShowGantt = false;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            IsLoaded = true;
        }
        private void ShowGanttCommand(object sender, RoutedEventArgs e)
        {

            try
            {



                if (IsShowGantt)
                {
                    IsShowGantt = false;
                    cAV37.IsShowGantt = IsShowGantt;
                    return;
                }
                ReSetTab();
                IsShowGantt = true;
                try
                {
                    cAV37.TBMain.Clear();
                    cAV37.TBMain.Merge(cAV33.TBMain);
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex.StackTrace, ex);
                    cAV37.TBMain.Clear();
                    cAV37.TBMain.Merge(cAV33.TBMain);
                }

                cAV37.IsShowGantt = IsShowGantt;
                MessageInfo msg = new MessageInfo();
                msg.Sender = this.RUNID;
                msg.MSGTYPE = "SSHOWGANT";
                msg.ACTION = "SSHOWGANT";
                VICC_WFEVENTS.SVWF.CheckEvents("UIMESSAGE", null, "", msg);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void RSPCommand(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            //VICC_WFEVENTS.SVWF.STSPINSPEED(RUNID, cAV33.KSTKRS, cAV33.KST, cAV33.AGANG, cAV33.AMTYP);
        }


        private void SSMCommand(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            //VICC_WFEVENTS.SVWF.SSTDM(RUNID, cAV33.KSTKRS, cAV33.KST, cAV33.AGANG, cAV33.AMTYP);

        }
        private void GMF02Command(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            VICC_WFEVENTS.SVWF.SGMF02(RUNID, cAV33.KSTKRS, cAV33.KST, cAV33.AGANG, cAV33.AMTYP);
        }
        private void AM21Command(object sender, RoutedEventArgs e)
        {
            ReSetTab();
            //VICC_WFEVENTS.SVWF.SAM21(RUNID, cAV33.KSTKRS, cAV33.KST, cAV33.AGANG, cAV33.AMTYP);
        }

    }
}
